<?

	$dir = pathinfo($_SERVER['SCRIPT_FILENAME']); 

	if (ini_set("include_path",ini_get("include_path").((strtoupper(PHP_OS) == "LINUX") ? ":" : ";").$dir['dirname']) === false) {
		echo "ERROR: Definicion en el include_path";
		exit;
	}

	include('adodb/adodb.inc.php');
	include_once('adodb/adodb-pager.inc.php');
    include_once('conf/dbconn_param.php');
	
	
	$db = ADONewConnection($dbdriver);
	$db->Connect($server, $user, $password, $database);
	$db->SetFetchMode(ADODB_FETCH_ASSOC);

    $db->debug = false;
	
	$sql = 'select * from corte_nacional where 1=-1';
    $rs = $db->Execute($sql);
    $temas = $rs->GetRows();
	
	$db->Close();
	
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Corte Nacional</title>

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml">

<style type="text/css" media="screen">
	@import "media/css/demo_page.css";
	@import "media/css/demo_table.css";
	@import "media/css/site_jui.css";
	@import "media/css/demo_table_jui.css";
	@import "media/css/themes/base/jquery-ui.css";
	@import "media/css/themes/smoothness/jquery-ui-1.7.2.custom.css";
	@import "media/css/TableTools.css";
	/*
	 * Override styles needed due to the mix of three different CSS sources! For proper examples
	 * please see the themes example in the 'Examples' section of this site
	 */
	
	.dataTables_info { padding-top: 0; }
	.dataTables_paginate { padding-top: 0; }
	.css_right { float: right; }
	#example_wrapper .fg-toolbar { font-size: 0.8em }
	#theme_links span { float: left; padding: 2px 10px; }
</style>

<script type="text/javascript" src="media/js/complete.js"></script>
<script src="media/js/jquery-1.6.2.js" type="text/javascript"></script>
<script src="media/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script type="text/javascript" src="media/js/jquery.dataTables.editable.js"></script>
<script src="media/js/jquery.jeditable.js" type="text/javascript"></script>
<script src="media/js/jquery-ui.js" type="text/javascript"></script>
<script src="media/js/jquery.validate.js" type="text/javascript"></script>
<script src="media/js/pagination.extra.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="media/js/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="media/js/TableTools.js"></script>

<script src="media/jAlert/jquery.alerts.js" type="text/javascript"></script>
<link href="media/jAlert/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function(){
	cargar_bloques();
	$("#bloque").change(function(){ver_variedad();});
	$("#categoria").change(function(){ver_enfermedad();});
	$("#variedad").attr("disabled",true);
	$("#enfermedad").attr("disabled",true);
});
function cargar_bloques()
{
	$.get("php/bloque.php", function(resultado){
		if(resultado == false)
		{
			alert("Error");
		}
		else
		{
			$('#bloque').append(resultado);			
		}
	});	
}
function ver_variedad()
{
	var code = $("#bloque").val();
	$.get("php/ver_variedad.php", { code: code },
		function(resultado)
		{
			if(resultado == false)
			{
				alert("Error");
			}
			else
			{
				$("#variedad").attr("disabled",false);
				document.getElementById("variedad").options.length=1;
				$('#variedad').append(resultado);			
			}
		}

	);
}

function cargar_categoria()
{
	$.get("php/categoria.php", function(resultado){
		if(resultado == false)
		{
			alert("Error");
		}
		else
		{
			$('#categoria').append(resultado);			
		}
	});	
}
function ver_enfermedad()
{
	var code = $("#categoria").val();
	$.get("php/ver_enfermedad.php", { code: code },
		function(resultado)
		{
			if(resultado == false)
			{
				alert("Error");
			}
			else
			{
				$("#enfermedad").attr("disabled",false);
				document.getElementById("enfermedad").options.length=1;
				$('#enfermedad').append(resultado);			
			}
		}

	);
}
</script>

<form id="formAddNewRow" action="php/AddDataNacional.php" title="" style="width:600px;">
	<label id="lblAddError" style="display:none" class="error"></label>

	<input type="hidden" name="cnc_id" id="cnc_id" value="0" rel="0" />
    <label for="fecha">Fecha</label>
	<input type="text" name="fecha" class="required" value="<? echo date("Y-m-d"); ?>" id="fecha" rel="1" />
    <br/>    

	<label for="bloque">Bloque</label>    
        <select name="bloque" class="required" id="bloque" rel="2">
            <option value="0">Seleccione...</option>
        </select>        
		<br/>

	<label for="variedad">Variedad</label>    
        <select name="variedad" class="required" id="variedad" rel="3">
            <option value="0">Seleccione...</option>
        </select>        
		<br/>

    <label for="categoria">Cat. Enfermedad</label>
    	<select name="categoria" class="required" id="categoria" rel="4">
            <option value="0">Seleccione...</option>
        </select>  
        <br/>        

    <label for="enfermedad">Enfermedad</label>
        <select name="enfermedad" class="required" id="enfermedad" rel="5">
            <option value="0">Seleccione...</option>
        </select>      	
        <br/>
    <label for="codigo">Tallos</label>
    	<input type="text" name="tallos" class="required" id="tallos" rel="6" />
        <br/>
			
	<div id="cargando" style="display:none; color: green;">Cargando...<br  /></div>
    
</form>

</body>
</html>